import argparse
import io


def pair_to_single(pair_fn, src_fn, tgt_fn):
    src_f = io.open(src_fn, "w", encoding="utf-8")
    tgt_f = io.open(tgt_fn, "w", encoding="utf-8")

    pairs = io.open(pair_fn, encoding="utf-8").readlines()
    for line in pairs:
        line = line.strip()
        if len(line) == 0:
            continue
        p = line.split("\t")
        if len(p) >= 2:
            src_f.write(p[0] + "\n")
            tgt_f.write(p[1] + "\n")


if __name__ == "__main__":
    argparser = argparse.ArgumentParser()
    argparser.add_argument("tsv_fn")
    argparser.add_argument("src_fn")
    argparser.add_argument("tgt_fn")
    args = argparser.parse_args()

    pair_fn = args.tsv_fn
    src_fn = args.src_fn
    tgt_fn = args.tgt_fn

    pair_to_single(pair_fn, src_fn, tgt_fn)


